# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: damir <damir@archlinux.org>
# Contributor: Lukas Sabota <punkrockguy318@comcast.net>
# Contributor: Brice Carpentier <brice@dlfp.org>

pkgname=scons
pkgver=4.2.0
pkgrel=1
pkgdesc="Extensible Python-based build utility"
arch=('any')
url="https://scons.org"
license=('MIT')
depends=('python')
makedepends=('python-setuptools' 'python-sphinx' 'python-sphinx_rtd_theme'
'rst2pdf')
checkdepends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/${pkgname}/${pkgname}/archive/${pkgver}.tar.gz")
sha512sums=('138573f7203b52fad0527d8d88ceabe182273eff7e4b74125e0d7eda51c44408b07e2c702ee63214519392101d8bbb30013e6d34000eaeb530a816c17396de97')
b2sums=('c298152db937810ab73afc304a9dc480c185ef0d6e86be5ec7f2022a7d1ed4d3df6ecc18148c3143d4e76a7ea0e50790db1224e66db68bace0759daba7f36a91')

prepare() {
  cd "${pkgname}-${pkgver}"
  # fix wrong build target
  sed -e 's/bdist_wheel/bdist/g' -i SConstruct
}

build() {
  cd "${pkgname}-${pkgver}"
  python scripts/scons.py --include-dir= -j1
  # copy man pages into place, so that install-data may pick them up
  cp -av build/doc/man/* .
}

check() {
  cd "${pkgname}-${pkgver}"
  python runtest.py --all --unit-only
}

package() {
  cd "${pkgname}-${pkgver}"
  python setup.py install --prefix=/usr \
                          --skip-build \
                          --optimize=1 \
                          --install-data=/usr/share/man/man1/ \
                          --root="$pkgdir"
  install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
  install -vDm 644 {{CHANGES,RELEASE}.txt,README.rst} \
    -t "${pkgdir}/usr/share/doc/${pkgname}/"
}
